package com.gadgets.busi.bm01.common;

import com.gadgets.busi.bm01.dto.ImgCopyRestDTO;
import com.gadgets.framework.common.exception.GadgetsValidateException;
import com.gadgets.framework.common.validator.AbstractBusiValidateTrigger;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * The type Txt copy rest validate trigger.
 *
 * @author UncleXiu
 * @version V1.0.0
 * @data 2020 -09-21
 */
@Component
public class ImgCopyRestValidateTrigger extends AbstractBusiValidateTrigger<ImgCopyRestDTO> {

    /**
     * 校验执行器
     *
     * @param target 目标对象
     *
     * @return 校验不通过信息
     *
     * @throws GadgetsValidateException 校验异常
     */
    @Override
    public String validate(ImgCopyRestDTO target) throws GadgetsValidateException {
        if(StringUtils.isEmpty(target.getPath())){
           return "拷贝路径不能为空";
        }else if(StringUtils.isEmpty(target.getCopyModuel())){
            return "拷贝模式不能为空";
        }else if(StringUtils.isEmpty(target.getTargetSite())){
            return "目标网站路径不能为空";
        }
        return null;
    }

}
